﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ctem.gui.SignalChart
{
    // направленность оси
    public enum TAxisDirection {LeftRight, DownUp};
    public class Axis
    {
        internal Point DrawStartPoint;
        internal Point DrawEndPoint;
        public Point StartPoint;
        public Point EndPoint;
        public TAxisDirection direct;
        private int mCountOfParts = 1;

        public Axis(Point _startP, Point _EndP, TAxisDirection _direct)
        {
            StartPoint = _startP;
            DrawStartPoint = _startP;
            DrawEndPoint = _EndP;
            EndPoint = _EndP;
            direct = _direct;
        }

        public int CountOfParts { get { return mCountOfParts; } set { if (value > 0) mCountOfParts = value; } }

        internal float Convert(float val)
        {
            if (direct == TAxisDirection.DownUp)
                return (StartPoint.Y - val);
            if (direct == TAxisDirection.LeftRight)
                return (val - StartPoint.X);
            return val;
        }

        public void Draw(Graphics g)
        {
            if (direct == TAxisDirection.LeftRight)
                g.DrawLine(new Pen(Color.Black), DrawStartPoint,DrawEndPoint);
                //g.DrawLine(new Pen(Color.Black), StartPoint,new Point(EndPoint.X,StartPoint.Y));
            if (direct == TAxisDirection.DownUp)
                g.DrawLine(new Pen(Color.Black), DrawStartPoint, DrawEndPoint);
                //g.DrawLine(new Pen(Color.Black), StartPoint,new Point(StartPoint.X,EndPoint.Y));
        }
    }
}
